using MediatR;
using PublicCommon;
using System.Reflection;
using T_Rbac_APi.Expention;
using T_Rbac_Rep;

namespace T_Rbac_APi
{
    public class Program
    {
        public static void Main(string[] args)
        {
            var builder = WebApplication.CreateBuilder(args);

            // Add services to the container.

            builder.Services.AddControllers();
            builder.Services.AddMediatR(Assembly.GetEntryAssembly());
            builder.Services.AddAutoMapper(AppDomain.CurrentDomain.GetAssemblies());
            builder.Services.AddJwt(builder);
            builder.Services.AddService();
            builder.Services.AddHttpClient();
            builder.Services.AddScoped<Cross_services_Helper>();
            builder.Services.AddDbcontextService<Mycreate>(builder.Configuration.GetConnectionString("Usecon"), true);
            // Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
            builder.Services.AddEndpointsApiExplorer();
            builder.Services.AddControllers().AddNewtonsoftJson(x => x.SerializerSettings.ContractResolver = new Newtonsoft.Json.Serialization.DefaultContractResolver());
            builder.Services.AddSwaggerGen(x =>
            {
                string path=AppDomain.CurrentDomain.BaseDirectory+ "T_Rbac_APi.xml";
                x.IncludeXmlComments(path, true);
            });

            var app = builder.Build();
            app.UseCors(x => x.AllowAnyOrigin().AllowAnyHeader().AllowAnyMethod());
            // Configure the HTTP request pipeline.
                app.UseSwagger();
                app.UseSwaggerUI();
            app.UseAuthorization();


            app.MapControllers();

            app.Run();
        }
    }
}
